<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>订单管理_{$webname}</title>
<!--公共样式开始-->
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/css/reset.css">
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/css/common.css">
<!--公共样式结束-->
<!--私有样式开始-->
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/css/page_order.css">
<!--私有样式结束-->
<!--FontAwesome开始-->
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/plugins/FontAwesome/css/font-awesome.min.css">
<!--FontAwesome结束-->
<!--核心JS开始-->
<script src="__PUBLIC__/Js/jquery.min.js" type="text/javascript"></script>
<script src="__PUBLIC__/Js/jquery-migrate-1.2.1.min.js" type="text/javascript"></script>
<!--核心JS结束-->
<script type="text/javascript">
	$(function(){
		$('#goBack').on('click',function(){
			window.history.back();
		});
		
		/*右侧导航点击事件*/
		$('.hb_right').click(function(){
			$(".wrapper").toggleClass("a");
			$(".nav_box").toggleClass("b");
		});
		
		/*右侧导航二级*/
		$('.erji').click(function(){
			$(this).find("ul").toggleClass("c");
		});
	});
</script>
</head>
<body>
<!-- 头部开始-->
<include file="Public:header"/>
<!-- 头部结束-->
<!--主体开始-->
<div id="pageHome">
	<!--主体盒子开始-->
    <div id="wrapper" class="wrapper radius_5 bg_white">
    	<!--面包屑导航开始-->
        <ul class="pagePosition clearfix">
        	<li><a href="{:U('Index/index')}"><i class="icon-home"></i> 首页</a></li>
            <li><i class="icon-angle-right"></i></li>
            <li><a href="#">订单列表</a></li>
        </ul>
        <!--面包屑导航结束-->
        <div class="space_hx"></div>
        <div>
        	<select name="status"  id="status" style="width:90%; padding:5px;">
				<option value="">请选择要查看的订单状态</option>
                <foreach name="select" item="v">
                	<option value="{$key}" <eq name="key" value="$map.status">selected</eq>>{$v}</option>
                </foreach>
            </select>
        </div>
        <!--订单列表开始-->
        <div id="detail_order" style="margin-top:20px;">
        <include file="Order:order_order" />
       	</div>

        <!--订单列表结束-->
    </div>
    <!--主体盒子结束 -->
    <!--导航盒子开始-->
    <include file="Public:menu" />
    <!--导航盒子结束-->
</div>
<script type="text/javascript" src="__PUBLIC__/Plugins/artDialog/jquery.artdialog.js?skin=bootstrap"></script>
<script type="text/javascript" src="__PUBLIC__/Plugins/artDialog/plugins/iframeTools.js"></script>
<script type="text/javascript">

var url = "{:U('Order/order_index')}";
function reloadOrder(){
	ajaxOrder(url);
}

function initLoad(){
	var status = $('#status').val();
	var urls   = url+"&status="+status;
	ajaxOrder(urls);
}

jQuery(document).ready(function() {
	
	initLoad();
	
	$('#status').on("change",function(){
		var url = "{:U('Order/order_index')}";
		url+="&status="+$(this).val();
		ajaxOrder(url);
	});
	
	//分配订单到门店
	$('.order_allot').live("click",function(){
		var id = $(this).attr("data-id");
		art.dialog.open('{:U("Order/order_allot")}'+'&id='+id,{
			title:'分配订单到门店', width:550,height:200,fixed:true,top:60
		});
	});
	
	//分配订单到门店配送员'
	$('.order_delivery').live("click",function(){
		var id = $(this).attr("data-id");
		art.dialog.open('{:U("Order/order_delivery")}'+'&id='+id,{
			title:'分配订单到门店配送员', width:500,height:200,fixed:true,top:60
		});
	});
	
	//退回订单
	$('.order_revert').live("click",function(){
		var id   = $(this).attr("data-id");
		var durl = "{:U('Order/order_revert')}";
		dealOrder(durl,id);
	});
	
	//配货完成
	$('.order_todelivery').live("click",function(){
		var id   = $(this).attr("data-id");
		var durl = "{:U('Order/order_todelivery')}";
		dealOrder(durl,id);
	});
	
	//确认收货
	$('.order_confirm').live("click",function(){
		var id   = $(this).attr("data-id");
		var durl = "{:U('Order/order_confirm')}";
		dealOrder(durl,id);
	});
	
	//客户拒签
	$('.order_refused').live("click",function(){
		var id   = $(this).attr("data-id");
		var durl = "{:U('Order/order_refused')}";
		dealOrder(durl,id);
	});
	
	//打印订单
	$('.order_print').live("click",function(){
		var id   = $(this).attr("data-id");
		art.dialog.open('{:U("Order/order_print")}'+'&id='+id,{
			title:'打印订单', width:320,height:400,fixed:true,top:60
		});
	});
});

function dealOrder(url,id){
	$.post(url,{'id':id},function(data){
		if(data.status == 1){
			reloadOrder();
		}
		art.dialog.alert(data.info);
	});
}

function ajaxOrder(url){
	$.ajax({
		url: url,
		dataType: "html",
		type: "get",
		cache: false,
		async:false,
		success: function(html){
			$("#detail_order").html(html);
			return false;
		}
	});
}
</script>
<!--主体结束-->
</body>
</html>